package Wakita;
import java.io.File;
import java.io.IOException;

public class Clustering implements WakitaConstants {

	/**
	 * @param args
	 */
	private String workingDirectory;

	private String binary;

	public Clustering(String workingDirectory, String binary) {
		this.workingDirectory = workingDirectory;
		this.binary = binary;
	}

	public void cluster(String inputFileName, String outputFileName, int algorithm) throws IOException, InterruptedException {
		String in = inputFileName;
		String out = workingDirectory + "\\" + outputFileName;
		String algo;
		switch (algorithm) {
		case CLAUSET:
			algo = "-Clauset";
			out = workingDirectory + "\\" + outputFileName + "-Clauset";
			break;
		case DANON:
			algo = "-Danon";
			out = workingDirectory + "\\" + outputFileName + "-Danon";
			break;
		case HN:
			algo = "-HN";
			out = workingDirectory + "\\" + outputFileName + "-HN";
			break;
		default:
			algo = "-Clauset";
			out = workingDirectory + "\\" + outputFileName + "-Clauset";
		}
		/* convert the data in the right format */
		
		String cmd = "cmd.exe /c "+binary+"\\clustering " + algo + " " + in + " " + out;
		System.out.println(cmd);
		// String path = "C:\\Users\\David\\Desktop\\katsura-clustering\\src";
		Process p = null;
		p = Runtime.getRuntime().exec(cmd, null, new File(workingDirectory));
		p.waitFor();
	}
}
